
Imports NUnit.Framework
Imports ValidationFramework

Namespace NewRule
    <TestFixture()> _
    Public Class RequiredCharacterRuleAttributeUsage

        Public Class Person
            Private _name As String

            <RequiredCharacterRule("s"c)> _
            Public Property Name() As String
                Get
                    Return _name
                End Get
                Set(ByVal value As String)
                    _name = value
                End Set
            End Property

        End Class

        <Test()> _
        Public Sub Run()
            Dim person As New Person
            Dim propertyValidationManager = ValidationManagerFactory.GetPropertyValidationManager(person)

            propertyValidationManager.Validate("Name")
            Assert.IsTrue(propertyValidationManager.IsValid)

            person.Name = "john"
            propertyValidationManager.Validate("Name")
            ' Invalid because Name does not contain an 's'
            Assert.IsFalse(propertyValidationManager.IsValid)

            person.Name = "simon"
            propertyValidationManager.Validate("Name")
            ' Valid because Name does contain an 's'
            Assert.IsTrue(propertyValidationManager.IsValid)
        End Sub
    End Class
End Namespace